<?php
//$HeadURL: http://instaforms.googlecode.com/svn/trunk/form.php $
//$Revision: 21 $
//$Date: 2012-08-31 08:07:56 +0000 (Fri, 31 Aug 2012) $
//$Author: dev@arbrebinaire.com $
/**
 * SHORT DESCRIPTION OF FILE
 *
 * LONG DESCRIPTION OF FILE
 *
 * PHP version 5
 *
 * @package    com.arbrebinaire.PACKAGENAME
 * @author     Francois Hetu <dev@arbrebinaire.com>
 * @copyright  2012 Francois Hetu
 * @version    SVN: $Id: form.php 21 2012-08-31 08:07:56Z dev@arbrebinaire.com $
 */
require_once 'lib/bootstrap.php';

$formId = 1;
$formAction = 'form.php';

try {
    $form = $imp->createForm($formId, $formAction);
    
    if (!$_POST || !$form->isValid($_POST)) {
        
        if($imp->formAcceptsAnswers($formId) && $imp->userHasAccessToForm($formId, null)){
            
            $imp->renderForm($formId);
            
        } else {
            
            echo $form->getOfflineMessage();
        }
    } else {
        // Filled and validated
        if($form->hasFileUpload()){
            $success = $form->receiveAllFiles();
            if($success){
                
            }
        }
        
        
        $values = $form->getValues();
        
        
        
        $imp->saveAnswer($formId, $values);
        
        $message = 'Values: ' .'<br />'.var_export(json_encode($values), true). '<br />'. '<br />';
        
        $message .= 'Post submit message:' . '<br />' . $form->getPostSubmitMessage(). '<br />'. '<br />';
        
        
        
        include "message.php";
    }
    
} catch (Exception $e) {
    
}